package com.starlink.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.starlink.model.domain.StarNurturingDO;
import com.starlink.model.request.StarNurturingRequest;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author zhanghong
 */
@Repository
public interface StarNurturingMapper extends BaseMapper<StarNurturingDO> {
    StarNurturingDO selectDOById(Long id);
    List<StarNurturingDO> selectDOList(StarNurturingDO starNurturing);
    int insertDO(StarNurturingDO starNurturing);
    int batchInsertDO(List<StarNurturingDO> starNurturingDOList);
    int updateDO(StarNurturingDO starNurturing);
    int deleteDOById(Long id);
    int deleteDOByIds(String[] ids);

    @Select({"<script>",
            "   select count(1) from star_nurturing",
            "   <where>",
            "       deleted=0",
            "       <if test=\"1==0\">and id=#{param.id}</if>",
            "   </where>",
            "</script>"})
    long pageCount(@Param("param") StarNurturingRequest param);
    @Select({"<script>",
            "   select * from star_nurturing",
            "   <where>",
            "       deleted=0",
            "       <if test=\"1==0\">and id=#{param.id}</if>",
            "   </where>",
            "   order by create_time desc limit #{limit} offset #{offset}",
            "</script>"})
    List<StarNurturingDO> pageQuery(@Param("param") StarNurturingRequest param, @Param("limit") int limit, @Param("offset") long offset);

    List<StarNurturingDO> listQuery(StarNurturingRequest request);
}
